__init__.py 688 B

12345678910111213141516171819
  1. import sys
  2. try:
  3. # Our match_hostname function is the same as 3.5's, so we only want to
  4. # import the match_hostname function if it's at least that good.
  5. if sys.version_info < (3, 5):
  6. raise ImportError("Fallback to vendored code")
  7. from ssl import CertificateError, match_hostname
  8. except ImportError:
  9. try:
  10. # Backport of the function from a pypi module
  11. from backports.ssl_match_hostname import CertificateError, match_hostname
  12. except ImportError:
  13. # Our vendored copy
  14. from ._implementation import CertificateError, match_hostname
  15. # Not needed, but documenting what we provide.
  16. __all__ = ("CertificateError", "match_hostname")